//
//  QWTipsAlertController.m
//  qwm
//
//  Created by kevin on 2023/3/28.
//

#import "QWTipsAlertController.h"
#import "QWLoginNotTipsView.h"

@interface QWTipsAlertController ()
@property (nonatomic, strong) QWLoginNotTipsView *loginNotView;
@end

@implementation QWTipsAlertController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    if(self.tipType == TipsAlertType_loginNot){
        [self loginNotView];
    }
    
    if(self.tipType == TipsAlertType_checkCode){
        [self checkCodeView];
    }
}

- (QWLoginNotTipsView *)loginNotView{
    if(!_loginNotView){
        _loginNotView = [[QWLoginNotTipsView alloc]init];
        __weak __typeof(self) weakSelf = self;
        _loginNotView.forkBlock = ^{
            __strong __typeof(weakSelf)strongSelf = weakSelf;
            [strongSelf dismissViewControllerAnimated:NO completion:nil];
        };
        [self.view addSubview:_loginNotView];
        
        [_loginNotView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self.view);
            make.centerY.equalTo(self.view);
            make.width.equalTo(self.view).offset(-50);
        }];
    }
    return _loginNotView;
}

- (QWCheckCodeView *)checkCodeView{
    if(!_checkCodeView){
        _checkCodeView = [[QWCheckCodeView alloc]init];
        __weak __typeof(self) weakSelf = self;
        _checkCodeView.forkBlock = ^{
            __strong __typeof(weakSelf)strongSelf = weakSelf;
            [strongSelf dismissViewControllerAnimated:NO completion:nil];
        };
        [self.view addSubview:_checkCodeView];
        
        [_checkCodeView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self.view);
            make.centerY.equalTo(self.view);
            make.width.equalTo(self.view).offset(-50);
        }];
    }
    return _checkCodeView;
}


- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    [self.view endEditing:YES];
}

@end
